def main():
    # dic_create_update()
    dic_read()

def dic_create_update():
    dic = {"小美": 18, "小帅": 19, "小丑": 20}
    # 方式一：有就覆盖，没有就新增
    dic["小美"] = 21
    # 方式二：有就不操作，没有就新增
    dic.setdefault("小美", 21)
    # 方式三：update
    dic.update({"小帅": 20, "小平": 18})
    print(dic.keys())


def dic_delete():
    dic = {"小美": 18, "小帅": 19, "小丑": 20}
    s1 = dic.pop("小美1", None)
    print(s1)


def dic_read():
    dic = {"小美": 18, "小帅": 19, "小丑": 20}
    # 一：没有返回None
    s1 = dic.get("小比")
    # 二：中括号的方式
    # s2 = dic["小比"]
    # 三：判断键是否在字典中
    if "小美" in dic:
        print(True)


if __name__ == '__main__':
    main()
